/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-06-26
 * Time: 19:54
 */
public class test4 {
    public int lengthOfLongestSubstring(String s) {
        int n = s.length();
        char[] ch = s.toCharArray();
        int left = 0,right=0;
        int ret = 0;
        int[] hash = new int[128];
        while(right<n){
            hash[ch[right]]++;
            while(hash[ch[right]]>1){
                hash[ch[left]]--;
                left++;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}
